/*
Kiwi Editor is a framework for building WYSIWYG web editors.
Copyright (C) 2011  Roosevelt de Lima Sardinha

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

Contact the author at roosevelt1@gmail.com (Roosevelt) 
*/

/* TextEO */
function textEO(){	
    this.showProperties = function(){
		this.tabId = this.propertyBox.addTab("Text");
		this.propertyBox.addProperty(this.tabId, 0, 0, 'content', 'FormatText', this, {
			label: 'Content',
			help: 'Sets the content of the text.'
		});
		this.setProperty(this.content);
    };
        
	this.setContent = function(content){
		this.content = content;
		this.div.innerHTML = content;
		if (this.editor) {
			this.editor.setContent(content);
			this.EOM.correctPosition(this.id);	
		}			
	}
	
	this.getContent = function(){
		var content = "";
		if (this.editor && this.selected) {
			content = this.editor.getContent();
		}else{
			content = this.content;
		}
		return content;
	}
	
    this.setProperty = function(property, value){
        // Changes the property of  this object setting it to value.
		switch (property) {
			case 'content':
				this.setContent(value);
				break;			
            default:
                break;
        }
    };
	
    this.getProperty = function(property){
        // Gets the property of  this object
        switch (property) {
			case 'content':
				return this.getContent();
				break;
            default:
                break;
        }
    };
    
    this.JSON = function(){
        var EO_JSON = {
			content: this.getProperty('content')
		};
        return EO_JSON;
    }
	
	this.HTML = function(){
		var html = "<div style=\"position: absolute; top: " + this.getProperty('top') + "; left: " + this.getProperty('left') + ";\">" + this.getProperty('content') + "</div>";
		
		return html;
	}
    
    this.help = "Adds some text to the document. You can format the text using the Content property in the property box.";
	
	this.objectList = new Array();
	this.selectorList = new Array();
	
    this.init = function(){              
		this.objectList.push('div');
		this.selectorList.push('div');
				
	    var div = document.createElement('div');
	    div.innerHTML = 'Insert your text here.'
	    div.style.cursor = 'move';
		this.div = div;
		
		this.setProperty('content', 'Insert your text here.');
    }
	

}
